package cn.akwangl.concurrency.web.event;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;
import org.springframework.stereotype.Component;

/**
 * Spring 事件发布器
 *
 * @author 阿坤同学
 * @date 2025/2/14 09:39
 */
@Component
public class PublishEvent implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    /**
     * 发送事件
     *
     * @author 阿坤同学
     * @date 2025/2/14 09:48
     */
    public void publishEvent(ApplicationEvent event) {
        applicationContext.publishEvent(event);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
